import { formatDataToUrl } from '../util/common';

export default function (url, data, method) {
  const config: any = {
    url: url,
    headers: {
      'X-Requested-With': 'XMLHttpRequest',
      'Content-Type': 'application/json;charset=UTF-8',
    },
    method
  }
  if (method === 'get') {
    config.url = formatDataToUrl(url, data)
  } else if (method === 'post') {
    config.data = data
  }
  wx.request(config);
}